package Experiment1;

/**
 * Created by zhangyunqi on 2017/9/26.
 */
public class LinkedListDemo {
    private Object[] objects;
    private int num;
    private Object[] elementData;


    public boolean isEmpty(int o) {
        if (objects == null) {
            return true;
        }
        return false;
    }

    public void add(int index, Object element) {
        Object ob = null;
        for (int i = 0; i < objects.length; i++) {
            if (i == index) {
                ob = objects[i];
                objects[i] = element;
                for (int j = i + 1; j < objects.length + 1; j++) {
                    objects[j + 1] = objects[j];
                    objects[j] = ob;
                }
            }
        }
    }



    public boolean contains(Object o) {
        return indexOf ( o ) >= 0;
    }


    public int indexOf(Object o) {
        int size=100;
        if (o == null) {
            for (int i = 0; i < size; i++)
                if (elementData[i] == null)
                    return i;
        } else {
            for (int i = 0; i < size; i++)
                if (o.equals ( elementData[i] ))
                    return i;
        }
        return -1;
    }
}
